import Vue from 'vue'
import Vuex from 'vuex'
import * as auth from '@/utils/auth'
import chat from './modules/chat'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userToken: auth.getToken() || {}
  },
  mutations: {
    // 设置token
    setToken (state, token) {
      state.userToken = token
      auth.setToken(token)
    },
    // 删除token
    delToken (state) {
      state.userToken = {}
      auth.delToken()
    }
  },
  actions: {
  },
  modules: {
    chat
  }
})
